home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 6 / CU Amiga Magazine's Super CD-ROM 06 (1996)(EMAP Images)(GB)(Track 1 of 4)[!][issue 1997-01].iso / cucd / prog / mui / muirexx2.2 / demos / muidir / deficon.rexx < prev    next >
OS/2 REXX Batch file  |  1996-04-28  |  3KB  |  72 lines

  1. /*
  2.  
  3. Code:       deficon.rexx
  4. Author:     Russell Leighton
  5. Revision:   11 Jan 1996
  6.  
  7. Comments:   This script tries to determine the file type of the named file.
  8. It returns the icon name for the file (or a default icon name) and a
  9. command and help string associated with the file type.  It makes use of the
  10. datatype.library function 'examinedt()'.
  11.  
  12. Note that this script should be edited to taste (mine is undoubtedly
  13. different from yours).
  14.  
  15. */
  16.  
  17. parse arg name .
  18.  
  19. call examinedt(name,dt.,STEM)
  20.  
  21. type = upper(dt.DataType)
  22.  
  23. if lastpos('/',name) ~= 0 then file = substr(name,lastpos('/',name)+1)
  24. else file = substr(name,lastpos(':',name)+1)
  25.  
  26. /* check for known datatypes. Note that some of the "command" strings only
  27. specify a port.  This will result in the command being set to the icons
  28. default tool. */
  29.  
  30. select
  31.     when pos('ASCII',type) = 1 then return iconname(name,'env:sys/def_ascii')||' HELP "Edit 'file'"'
  32.     when pos('JFIF',type) = 1 then return iconname(name,'env:sys/def_picture')||' HELP "View 'file'"'
  33.     when pos('GIF',type) = 1 then return iconname(name,'env:sys/def_picture')||' HELP "View 'file'"'
  34.     when pos('ILBM',type) = 1 then return iconname(name,'env:sys/def_ILBM')||' HELP "View 'file'"'
  35.     when pos('ANIM',type) = 1 then return iconname(name,'env:sys/def_anim')||' HELP "Play 'file'"'
  36.     when pos('C-SOURCE',type) = 1 then return iconname(name,'env:sys/def_c')||' HELP "Edit 'file'"'
  37.     when pos('AMIGAGUIDE',type) = 1 then return iconname(name,'env:sys/def_AmigaGuide')||' HELP "View 'file'"'
  38.     when pos('POSTSCRIPT',type) = 1 then return iconname(name,'env:sys/def_postscript')||' HELP "View 'file'"'
  39.     when pos('LHA',type) = 1 then return iconname(name,'env:sys/def_archive')||' HELP "View/Extract 'file'"'
  40.     when pos('8SVX',type) = 1 then return iconname(name,'env:sys/def_8SVX')||' HELP "Play 'file'"'
  41.     when pos('BINARY',type) = 1 then return findicon(name)
  42.     otherwise return iconname(name,'env:sys/def_project')||' HELP "'file'"'
  43. end
  44. exit
  45.  
  46. /* this procedure is called when a generic binary type is encountered.
  47. Additional file types could (and should) be added here if no appropriate 
  48. datatype exists. */
  49.  
  50. findicon:
  51.     arg name
  52.     select
  53.         when index(name,'.DVI') ~= 0 then return iconname(name,'env:sys/def_project')||' HELP "Preview 'file'"'
  54.         when index(name,'.MOD') ~= 0 then return iconname(name,'env:sys/def_mod')||' HELP "Play 'file'"'
  55.         when index(name,'MOD.') ~= 0 then return iconname(name,'env:sys/def_mod')||' HELP "Play 'file'"'
  56.         otherwise return iconname(name,'env:sys/def_project')||' HELP "'file'"'
  57.     end
  58. return
  59.  
  60. /* this procedure extracts the icon name.  Note that the icon name is the
  61. .info file name without the .info extension.  If the passed argument
  62. contains the .info extension it is removed.  Otherwise the existence of an
  63. associated .info file is checked and the original file name is returned if
  64. found, else the second argument is returned (presumably containing the name
  65. of a default icon).  */
  66.  
  67. iconname:
  68.     if index(upper(arg(1)),'.INFO') > 1 then return substr(arg(1),1,pos('.INFO',upper(arg(1)))-1)
  69.     if exists(arg(1)'.info') then return '"'arg(1)'"'
  70.     else return arg(2)
  71. return
  72.